import 'package:flutter/material.dart';

showSnackBar(BuildContext context, String message,
    {Duration duration = const Duration(milliseconds: 1200)}) {
  Scaffold.of(context).showSnackBar(SnackBar(
    duration: duration,
    content: Text(message),
    action: SnackBarAction(
      label: "OK",
      onPressed: () {
        //Navigator.of(context).pop();
      },
    ),
  ));
}
showAlertDialog(BuildContext context,Widget title,Widget content,List<Widget> actions) async {
 return await showDialog(
      barrierDismissible: false,
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: title,
          content: content,
          actions: actions,
        );
      });
}
showWarningAlertDialog(BuildContext context,String content) async {
  return await showDialog(
      barrierDismissible: false,
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Container(child: Icon(Icons.warning,color: Colors.orange,),alignment: Alignment.centerLeft,),
          content: Text(content),
          actions: <Widget>[
            FlatButton(
              child: Text("确定",style: TextStyle(color: Theme.of(context).primaryColor),),
              onPressed: () {
                Navigator.pop(context, "OK");
              },
            ),
            FlatButton(
              child: Text("取消",style: TextStyle(color: Theme.of(context).primaryColor)),
              onPressed: () {
                Navigator.pop(context, "CANCLE");
              },
            ),
          ],
        );
      });
}
